package cn.droidlover.xdroidmvp.net;

import cn.droidlover.xdroidmvp.kit.NLog;

/**
 * Created by wanglei on 2016/12/24.
 */

public class NetError extends Exception {
    private Throwable exception;
    private int type = NoConnectError;

    public static final int ParseError = -1000;   //数据解析异常
    public static final int NoConnectError = -1001;   //无连接异常
    public static final int AuthError = -1002;   //用户验证异常
    public static final int NoDataError = -1003;   //无数据返回异常
    public static final int BusinessError = -1004;   //业务异常
    public static final int OtherError = -1005;   //其他异常

    public NetError(Throwable exception, int type) {
        this.exception = exception;
        this.type = type;
    }

    public NetError(String detailMessage, int type) {
        super(detailMessage);
        this.type = type;
    }


    @Override
    public String getMessage() {
        if (exception != null) {
            return exception.getMessage();
        }
        return super.getMessage();
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return "NetError{" +
                "exception=" + exception +
                ", type=" + type +
                '}';
    }
}
